package com.light.wanting.emoji.store;

import com.light.applet.common.config.CommonQiniuConfig;
import com.light.applet.common.config.QiniuConfig;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.Map;

/**
 * @author: 魏彪
 */
@Component
@Primary
public class ContentFileStoreHolder implements InitializingBean {

    @Autowired
    private QiniuConfig qiniuConfig;

    private final Map<String, CommonQiniuConfig> configMap = new HashMap<>();

    public CommonQiniuConfig findBucket(String bucketName) {
        return configMap.get(bucketName);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        configMap.put("emoji", qiniuConfig.getEmoji());
        configMap.put("avatar", qiniuConfig.getAvatar());
        configMap.put("shortVideo", qiniuConfig.getShortVideo());
    }
}
